/*
X2Play
Copyright (C) 2008  Jitu Das

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef X2PLAY_H
#define X2PLAY_H

#include "xmms2conn.h"

#include <QWidget>
#include <QPainter>
#include <QBitmap>
#include <QDesktopWidget>
#include <QApplication>
#include <QRect>
#include <QLineEdit>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QPushButton>
#include <QKeyEvent>
#include <QAction>

class SearchLineEdit;

class X2Play : public QWidget
{
	Q_OBJECT
public:
	X2Play(QApplication *app, QWidget *parent = 0);
	QTreeWidget* getResultBox();

private:
	QApplication *app;
	QPixmap window;
	XMMS2Conn *conn;
	QPoint dragPosition;
	
	// components
	SearchLineEdit *searchBox;
	QTreeWidget *resultBox;
	QPushButton *btnPlay;
	QPushButton *btnQueue;
	QPushButton *btnCancel;

protected: 
	void paintEvent(QPaintEvent *event);
	void mouseMoveEvent(QMouseEvent *event);
	void mousePressEvent(QMouseEvent *event);

public slots:
	void searchTextChanged(const QString &text);
	void updateMatches(QList<QStringList> &);
	void playClicked(bool queue=false);
	void queueClicked();
	void cancelClicked();
	void toggle();
};

class SearchLineEdit : public QLineEdit
{
	Q_OBJECT
public:
	SearchLineEdit(QWidget *parent);
protected:
	void keyPressEvent(QKeyEvent *event);
};

#endif

